package com.yanfan.protocol.serialPort.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
@ConfigurationProperties("serial-port")
@Data
public class SerialPortProperties {

    /**
     * 波特率
     */
    //@Value("${serialPort.baudRate}")
    private Integer baudRate;

    /**
     * 数据位
     */
    //@Value("${serialPort.dataBits}")
    private Integer dataBits;

    /**
     * 启动时是否关闭
     */
    private Boolean isOpen;

    private static Integer staticBaudRate;
    private static Integer staticDataBits;

    @PostConstruct
    public void init() {
        staticBaudRate = baudRate;
        staticDataBits = dataBits;
    }

    public static Integer getStaticBaudRate() {
        return staticBaudRate;
    }

    public static Integer getStaticDataBits() {
        return staticDataBits;
    }
}
